<?php
class TdPage extends TdRenderer {
	
	  public $sql_con;
	  public $title;
	  public $webroot;
	  public $classname;
	  public $lynks;
	  public $styles;
	  public $scripts;
	
	  function __construct($title="", $template="") {
    
			global $teardrop;			

		    $this->webroot = $GLOBALS["webroot"];
		    
		    $this->title = $title;
		    
		    if ($template != "") {
		      parent::__construct($template);
		    }
		    else {
		      $tpl = preg_replace('/(.*)\.php.*$/', '${1}', $teardrop->page_controller);

		      parent::__construct($tpl.".phtml");
		      
		    }
		
		    if ($teardrop->page_path != "") {
		      $this->classname = $teardrop->page_path."/".$teardrop->page_class;
		    }
		    else {
		      $this->classname = $teardrop->page_class;
		    }	    

		    $dbinstance = $teardrop->config['default_db'];
		    if ($dbinstance != "") {
		    	if ($teardrop->config['db'][$dbinstance]['driver'] == 'mysql') {
		        $this->sql_con = new TdMySql($dbinstance);
		    	}
		    }
	    
	  }
	  
	  
		function __destruct() {
	  	
	  		$this->sql_con->close();  	
	  	
	  }
}
?>
